<?php if ($this->_var['action'] == 'agreement'): ?>

<div class="rule">
    <div class="list">
        <img class="list1" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/rule-list1.png" alt="活动规则">
        <img class="list2" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/rule-list2.png" alt="活动规则">
        <img class="list3" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/rule-list3.png" alt="活动规则">
    </div>
    <div class="text">最终解释权归六象元一网络有限公司所有</div>
    <?php if ($this->_var['sign']): ?>
    <div class="read">
        <img class="read1" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/read1.png" alt="已选">
        <img class="read2" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/read2.png" alt="未选">
        <img class="read3" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/read3.png" alt="已阅读活动协议">
    </div>
    <a id="write-data">
        <div class="next">下一步</div>
    </a>
    <?php endif; ?>
</div>
<script type="text/javascript">
//点击已阅读
$('.read .read1').click(function(){
    $(this).hide();
    $('.read .read3').show();
    $('.rule .next').css('background-color', '#a21c23');
    $('#write-data').attr('href','freeplan.php?act=write_data');
});
//点击未阅读
$('.read .read3').click(function(){
    $(this).hide();
    $('.read .read1').show();
    $('.rule .next').css('background-color', '#999999');
    $('#write-data').removeAttr('href');
});
</script>

<?php endif; ?>

<?php if ($this->_var['action'] == 'write_data' || $this->_var['action'] == 'save_school'): ?>

<div class="write">
    <img class="top" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/rank-inpage-top.jpg" alt="奖金排行榜">
    
    <div class="year-bg"></div>
    <div class="year">
        <div class="head">
            选择您的高考年份（报名后不能修改）
            <img class="year-arrow" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/year-arrow.png">
        </div>
        <div class="row" att="2015">2015年</div>
        <div class="row" att="2016">2016年</div>
        <div class="row" att="2017">2017年</div>
    </div>
    <form id="data-form" class="data-list" method="post" action="freeplan.php?act=done">
        <div class="data-row">
            <span class="point">*</span>
            <span>参加高考年份：</span>
            <input id="year" name="data_0" type="text" readonly="true" value="<?php echo $this->_var['temp_data']['0']; ?>" placeholder="选择您的高考年份，报名后不能修改">
        </div>
        <div class="data-row">
            <span class="point">*</span>
            <span>真实姓名：</span>
            <input type="text" name="data_1" value="<?php echo $this->_var['temp_data']['1']; ?>" placeholder="请填写真实姓名">
        </div>
        <div class="data-row">
            <span class="point">*</span>
            <span>身份证：</span>
            <input type="text" name="data_2" value="<?php echo $this->_var['temp_data']['2']; ?>" placeholder="请填写真实身份证号码">
        </div>
        <div class="data-row">
            <span class="point">*</span>
            <span>联系电话：</span>
            <input type="text" name="data_3" value="<?php echo $this->_var['temp_data']['3']; ?>" placeholder="请填写现用联系电话">
        </div>
        <div class="data-row">
            <span class="point">&nbsp;</span>
            <span>备用电话：</span>
            <input type="text" name="data_4" value="<?php echo $this->_var['temp_data']['4']; ?>" placeholder="可填写亲戚朋友手机号码">
        </div>
        <div class="data-row">
            <span class="point">*</span>
            <span>联系邮箱：</span>
            <input type="text" name="data_5" value="<?php echo $this->_var['temp_data']['5']; ?>" placeholder="请填写常用联系邮箱">
        </div>
        <div class="data-row" id="schoolname">
            <span class="point">*</span>
            <span>就读学校：</span>
            <input type="text" readonly="true" name="data_6" value="<?php echo $this->_var['temp_data']['11']; ?>" placeholder="选择就读学校">
        </div>
        <div class="data-row">
            <span class="point">*</span>
            <span>理想美院：</span>
            <input type="text" readonly="true" id="academy" name="data_7" value="<?php echo $this->_var['temp_data']['7']; ?>" placeholder="选择您最喜欢的美院">
        </div>
        
        <input type="hidden" name="data_8" value="1">
        <input type="hidden" name="data_9" value="<?php echo $this->_var['temp_data']['8']; ?>">
        <input type="hidden" name="data_10" value="<?php echo $this->_var['temp_data']['9']; ?>">
        <input type="hidden" name="data_11" value="<?php echo $this->_var['temp_data']['10']; ?>">
    </form>
    <div class="data-confirm" onclick="confirmCheck();">立即报名</div>
    <div class="school">
        <div class="school-head">
            <span>选择您最喜欢的美院</span>
            <img class="school-arrow" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/year-arrow.png">
        </div>
        <div class="school-row">
            <span>中央美术学院</span>
        </div>
        <div class="school-row">
            <span>清华大学美术学院</span>
        </div>
        <div class="school-row">
            <span>中国美术学院</span>
        </div>
        <div class="school-row">
            <span>天津美术学院</span>
        </div>
        <div class="school-row">
            <span>广州美术学院</span>
        </div>
        <div class="school-row">
            <span>湖北美术学院</span>
        </div>
        <div class="school-row">
            <span>四川美术学院</span>
        </div>
        <div class="school-row">
            <span>鲁迅美术学院</span>
        </div>
        <div class="school-row">
            <span>西安美术学院</span>
        </div>
    </div>
</div>
<script type="text/javascript">
/* 填写高考年份 */
$('#year').focus(function(){
    $('.write .year-bg,.write .year').show();
});
$('.write .year-bg').click(function(){
    $('.write .year-bg,.write .year,.write .school').hide();
});
/* 选择年份 */
$('.write .year .row').click(function(){
    var year = $(this).attr('att');
    $('#year').val(year);
    $('.write .year-bg,.write .year').hide();
});

/*
 * 选择就读学校
 * 由于要跳转到其他页面选择省市区学校
 * 所以要先把填好的数据通过ajax传到freeplan.php，再保存到session中
 */
$('#schoolname').click(function(){
    var data_arr = new Array();
    $(':input').each(function(i,element){
        data_arr[i] = $(this).val();
    });
    var url = 'freeplan.php?act=save_temp';
    $.ajax({url:url, data:{temp_data:data_arr}, type:'post', dataType:'json', success:function(result){
            if(result.message = 1){
            window.location.href = 'freeplan.php?act=location&type=province';
            }
        }
    });
});

/* 选择理想美院 */
$('#academy').focus(function(){
    $('.write .year-bg,.write .school').show();
});

/* 选择理想美院 */
$('.school-row').click(function(){
    var school = $(this).find('span').text();
    $('#academy').val(school);
    $('.write .year-bg,.write .year,.write .school').hide();
});

/* 最后确认填写信息 */
function confirmCheck(){
    var check = 1;
    $(":input").each(function(){
        // 参加高考年份

        if($(this).attr('name') == 'data_0' && !$(this).val()){
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
        // 真实姓名
        if($(this).attr('name') == 'data_1' && !$(this).val()){
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
        // 身份证
        if( $(this).attr('name') == 'data_2' && $(this).val().length != 18){
            $(this).css('color','#A21C23');
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
        if($(this).attr('name') == 'data_2' && $(this).val().length == 18){
            // 判断身份证是否已报名
            var url = 'freeplan.php?act=ajax_check_id';
            $.ajax({url:url, data:{data_2:$(this).val()}, type:'post', dataType:'json', success:function(result){
                    if(result.error>0){
                        check = 0;
                        alert('此身份已被使用');
                    }
                }
            });
        }
        // 联系电话
        if($(this).attr('name') == 'data_3' && $(this).val().length != 11){
            $(this).css('color','#A21C23');
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
        // 联系邮箱
        if ( $(this).attr('name') == 'data_5' ){
            var search_str = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
            var email_val = $(this).val();
            if(!search_str.test(email_val)){
                $(this).css('color','#A21C23');
                $(this).parent().css('border-bottom','1px solid #A21C23');
                check = 0;
            }
        }
        // 就读学校
        if( $(this).attr('name') == 'data_6' && !$(this).val() ){
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
        // 理想美院
        if( $(this).attr('name') == 'data_7' && !$(this).val() ){
            $(this).parent().css('border-bottom','1px solid #A21C23');
            check = 0;
        }
    });
    if( check == 1 ){
        $('#data-form').submit();
    }
}
</script>

<?php endif; ?>

<?php if ($this->_var['action'] == 'location'): ?>

<div class="loca-index">
    <?php if ($this->_var['type'] == 'province'): ?>
    <?php $_from = $this->_var['province_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['list']):
?>
    <a href="freeplan.php?act=location&type=city&parent_id=<?php echo $this->_var['list']['region_id']; ?>&region_name=<?php echo $this->_var['list']['region_name']; ?>">
        <div class="loca-row">
            <span><?php echo $this->_var['list']['region_name']; ?></span>
        </div>
    </a>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    <?php elseif ($this->_var['type'] == 'city'): ?>
    <?php $_from = $this->_var['city_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['list']):
?>
    <a href="freeplan.php?act=location&type=district&parent_id=<?php echo $this->_var['list']['region_id']; ?>&region_name=<?php echo $this->_var['list']['region_name']; ?>">
        <div class="loca-row">
            <span><?php echo $this->_var['list']['region_name']; ?></span>
        </div>
    </a>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    <?php elseif ($this->_var['type'] == 'district'): ?>
    <?php $_from = $this->_var['district_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['list']):
?>
    <div class="loca-row loca-row2">
        <input type="hidden" value="<?php echo $this->_var['list']['region_id']; ?>">
        <span><?php echo $this->_var['list']['region_name']; ?></span>
    </div>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    <div class="school-bg"></div>
    <div class="school">
        <span>学校名称</span>
        <form id="school-form" class="school-form" method="post" action="freeplan.php?act=save_school">
            <input class="school-name" type="text" name="data_11" value="">
            <div class="btn" onclick="schoolCheck();">完成</div>
        </form>
    </div>
    <?php endif; ?>
</div>

<script type="text/javascript">
/*
 * 把区信息通过ajax传到freeplan.php，保存到session中
 * 并显示填写学校信息
*/
$('.loca-row2').click(function(){
    var district = $(this).children().val();
    var url = 'freeplan.php?act=save_district';
    $.ajax({url:url, data:{district:district}, type:'post', dataType:'json', success:function(result){
            if(result.message = 1){
               $('.school-bg,.school').show();
            }
        }
    });
});
$('.school-bg').click(function(){
    $('.school-bg,.school').hide();
});

/* 验证填写的学校信息 */
function schoolCheck(){
    if(!$('.school-name').val()){
        $('.school-name').css('border','1px red solid');
    }else{
        $('#school-form').submit();
    }
}
</script>
<?php endif; ?>

<?php if ($this->_var['action'] == 'done'): ?>

<div class="succ-index">
    <div class="head">
        <img class="head1" src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/success.png" alt="报名成功">
        <p>
            恭喜您报名成功<br />
            加油！美院门口见。
        </p>
    </div>
    <div class="info">
        <div class="name-year">
            <span class="span1"><?php echo $this->_var['data']['realname']; ?></span>
            <span class="span2">参加高考年份：<?php echo $this->_var['data']['exam_year']; ?></span>
        </div>
        <p>
           身份证： <?php echo $this->_var['data']['idcardnumber']; ?><br />
           联系电话：<?php echo $this->_var['data']['mobile']; ?><br />
           常用邮箱：<?php echo $this->_var['data']['email']; ?><br />
           就读学校：<?php echo $this->_var['data']['schoolname']; ?>
        </p>
    </div>
    <div class="pick-code">
        <a href="http://pan.baidu.com/share/init?shareid=1898491918&uk=89062392">名家高清画作领取</a>
        <span>&nbsp;&nbsp;提取码：2w46</span>
    </div>
    <div class="recommend-head">名师推荐</div>
    <div class="reco-list">
        <?php $_from = $this->_var['teacher_recommend_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'item_0_71180700_1443348855');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['item_0_71180700_1443348855']):
?>
        <a class="box" href="<?php echo $this->_var['item_0_71180700_1443348855']['url']; ?>">
            <div class="reco-row">
                <img src="../<?php echo $this->_var['item_0_71180700_1443348855']['goods_thumb']; ?>">
                <span class="span1"><?php echo $this->_var['item_0_71180700_1443348855']['goods_name']; ?></span>
                <?php if ($this->_var['item_0_71180700_1443348855']['goods_id'] == 628): ?>
                <span class="span2">高质量橡皮，擦拭不留痕，画面整体和细节都能坚固，目前艺考生中使用最多的像皮。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 521): ?>
                <span class="span2">高级强粘性，柔和过度画面，不掉色不黏手，目前艺考生中使用最多的可塑橡皮。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 750): ?>
                <span class="span2">软硬适中，轻重变化，可大大丰富画面效果，目前艺考生中使用最多的秀丽笔。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 1733): ?>
                <span class="span2">
                防水，笔尖相比樱花更长，更耐用，适用细线勾画。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 1346): ?>
                <span class="span2">
                防水，笔尖相比樱花更软，笔压效果更好，适用粗线勾画。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 1017): ?>
                <span class="span2">
                果冻颜料的开创者，不再为挑颜料而烦恼。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 316): ?>
                <span class="span2">
                中国画材界老品牌95年，马利颜料是艺考生中历年来用得最多的品牌。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 1070): ?>
                <span class="span2">
                懂你的色彩，像油画般的笔触感。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 369): ?>
                <span class="span2">
                艺考生中认为最白的颜料，温莎是世界最优质颜料品牌。</span>
                <?php elseif ($this->_var['item_0_71180700_1443348855']['goods_id'] == 437): ?>
                <span class="span2">
                业界首创水平仪平衡最稳画架，轻便易于携带，写生首选。</span>
                <?php endif; ?>
            </div>
        </a>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </div>
    <a class="libao" href="activity.php" title="劲惠礼包">
        <img src="<?php echo $this->_var['__PUCM__']; ?>img/freeplan/libao.jpg">
    </a>
    <a class="back" href="freeplan.php" title="回到首页">回到首页</a>
</div>

<?php endif; ?>